package com.daguchuangyi.erp_android.model;

import android.os.Parcel;
import android.os.Parcelable;

import com.luck.picture.lib.entity.LocalMedia;

/**
 * Created by lijianjian on 2018/4/9.
 */

public class LocalMediaWrapper implements Parcelable {
    private LocalMedia mLocalMedia;
    private float[] mCutPoint;

    public LocalMedia getLocalMedia() {
        return mLocalMedia;
    }

    public void setLocalMedia(LocalMedia localMedia) {
        mLocalMedia = localMedia;
    }

    public float[] getCutPoint() {
        return mCutPoint;
    }

    public void setCutPoint(float[] cutPoint) {
        mCutPoint = cutPoint;
    }

    public int getX() {
        return (int) mCutPoint[0];
    }

    public int getY() {
        return (int) mCutPoint[1];
    }

    public int getHeight() {
        return (int) (mCutPoint[7] - mCutPoint[1]);
    }

    public int getWidth() {
        return (int) (mCutPoint[2] - mCutPoint[0]);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeParcelable(this.mLocalMedia, flags);
        dest.writeFloatArray(this.mCutPoint);
    }

    public LocalMediaWrapper() {
    }

    protected LocalMediaWrapper(Parcel in) {
        this.mLocalMedia = in.readParcelable(LocalMedia.class.getClassLoader());
        this.mCutPoint = in.createFloatArray();
    }

    public static final Parcelable.Creator<LocalMediaWrapper> CREATOR = new Parcelable.Creator<LocalMediaWrapper>() {
        @Override
        public LocalMediaWrapper createFromParcel(Parcel source) {
            return new LocalMediaWrapper(source);
        }

        @Override
        public LocalMediaWrapper[] newArray(int size) {
            return new LocalMediaWrapper[size];
        }
    };
}
